package com.micro.glszh.stat.controller;

import com.micro.glszh.stat.base.CommonResult;
import com.micro.glszh.stat.domain.BizDiseaseDetail;
import com.micro.glszh.stat.interceptor.AuthCheck;
import com.micro.glszh.stat.service.BizDiseaseDetailService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * BizDiseaseDetailController
 *
 * @Author gaopengfei
 * @create 2024/10/21 16:11
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@Api(tags = "病假")
@RequestMapping("/api/bizDiseaseDetail")
public class BizDiseaseDetailController {

    private final BizDiseaseDetailService bizDiseaseDetailService;

    @AuthCheck
    @ApiOperation("删除一条病假")
    @DeleteMapping("/{id}")
    public CommonResult<Boolean> deleteDiseaseDetail(@PathVariable Long id) {
        return CommonResult.success(bizDiseaseDetailService.removeById(id));
    }

    @AuthCheck
    @ApiOperation("根据recordId 获取事件列表")
    @GetMapping("/{recordId}")
    public CommonResult<List<BizDiseaseDetail>> selectDiseaseDetailList(@PathVariable Long recordId) {
        return CommonResult.success(bizDiseaseDetailService.selectDiseaseDetailList(recordId));
    }

    @AuthCheck
    @ApiOperation("新增或修改用户")
    @PostMapping()
    public CommonResult<Boolean> insertOrUpdateDiseaseDetail(@Validated @RequestBody List<BizDiseaseDetail> bizDiseaseDetailList) {
        return CommonResult.success(bizDiseaseDetailService.saveOrUpdateBatch(bizDiseaseDetailList));
    }
}
